package com.example.wx_zl_gzh_demo.service.impl;

import com.example.wx_zl_gzh_demo.config.MessageConfig;
import com.example.wx_zl_gzh_demo.entity.message.Article;
import com.example.wx_zl_gzh_demo.entity.message.NewsMessage;
import com.example.wx_zl_gzh_demo.entity.message.TextMessage;
import com.example.wx_zl_gzh_demo.service.WxService;
import com.thoughtworks.xstream.XStream;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Map;

/**
 * $
 $ * @return $
 * @author $
 * @description TODO
 * @date $ $
 */
@Service
public class WxServiceImpl implements WxService {

    @Autowired
    private MessageConfig messageConfig;


    @Override
    public String getReplyTextMessage(Map<String, Object> map, String content) {
        TextMessage textMessage = new TextMessage();
        textMessage.setFromUserName((String) map.get("ToUserName"));
        textMessage.setToUserName((String) map.get("FromUserName"));
        textMessage.setMsgType("text");
        textMessage.setContent(content);
        textMessage.setCreateTime(System.currentTimeMillis() / 1000);

        XStream xstream = new XStream();
        xstream.processAnnotations(TextMessage.class);
        String xml = xstream.toXML(textMessage);
        return xml;
    }
}
